package cn.com.qing.mydb.dbhelp.help;

import java.sql.Connection;
import java.sql.DriverManager;
import java.util.LinkedHashMap;

public class DBConnection {
	
	public static Connection getConnect(LinkedHashMap<String, Object> properties) {
		Connection con = null;
		@SuppressWarnings("unchecked")
		LinkedHashMap<String, Object> jp = (LinkedHashMap<String, Object>) properties.get("jdbc");
		try {
			Class.forName((String) jp.get("driver"));
			con = DriverManager.getConnection(
					"jdbc:mysql://"
					+(String)jp.get("ip")
					+":"
					+(Integer)jp.get("port")
					+"/"
					+(String)jp.get("database")
					+"?"
					+(String)jp.get("params"),
					(String)jp.get("user"),
					(String)jp.get("password"));
		} catch (Exception e) {
			e.printStackTrace();
		}
		return con;

	}
}
